﻿using System.Configuration.Provider;
using NCMIS.ObjectModel.MetaData;
using NCMIS.Produce;

namespace NCMIS.Provider
{
    /// <summary>
    /// Provides the base implementation for the Repository Provider for the repository services. The repository services
    /// allows the discovery of information about a repository and the object-types defined in it.
    /// </summary>
    public abstract class RepositoryProviderBase : ProviderBase
    {
        /// <summary>
        /// When implemented in a derived class, retreives all repositories exposed by this service.
        /// </summary>
        /// <returns>Collection of repositories.</returns>
        public abstract RepositoryEntry[] GetRepositories();

        /// <summary>
        /// When implemented in a derived class, returns a specific repository.
        /// </summary>
        /// <param name="repositoryId">The repository id.</param>
        /// <returns>The specified repository entry.</returns>
        public abstract RepositoryEntry GetRepository(string repositoryId);

        /// <summary>
        /// When implemented in a derived class, retreives information about the specified CMIS repository.
        /// </summary>
        /// <param name="repositoryId">The repository id.</param>
        /// <returns>RepositoryInfo object for specified repository.</returns>
        public abstract RepositoryInfo GetRepositoryInfo(string repositoryId);

        /// <summary>
        /// When implemented in a derived class, retrieves the collection with base types of a repository. Will only retrieve the base types,
        /// independant of parameters supplied.
        /// </summary>
        /// <param name="repositoryId">The repository id.</param>
        /// <param name="typeId">The type id of an object-type to retreive children for.</param>
        /// <param name="includePropertyDefinitions">If true propertydefintions will be returned for each returned object-type.</param>
        /// <param name="maxItems">The maximum number of items to return in the response. (optional)</param>
        /// <param name="skipCount">The number of potential results to skip before returning any results.</param>
        /// <returns>The specified base types.</returns>
        public abstract TypeDefinitionList GetTypeChildren(string repositoryId, string typeId, bool includePropertyDefinitions, int? maxItems, int skipCount);

        /// <summary>
        /// When implemented in a derived class, retreives the collection with type descendants for a repository type.
        /// </summary>
        /// <param name="repositoryId">The id of the repository.</param>
        /// <param name="typeId">The type id of an object-type to retreive children for.</param>
        /// <param name="depth">The number of levels of depth in the type hierachy from which to return results. If null is supplied, defaults to value: 2.</param>
        /// <param name="includePropertyDefinitions">If true propertydefintions will be returned for each returned object-type.</param>
        /// <returns>The specified type's descendants.</returns>
        public abstract TypeContainer[] GetTypeDescendants(string repositoryId, string typeId, int? depth, bool includePropertyDefinitions);

        /// <summary>
        /// When implemented in a derived class, retreives the type definition for specified type.
        /// </summary>
        /// <param name="repositoryId">The id of the repository.</param>
        /// <param name="typeId">The type id of an object-type to retreive definition for.</param>
        /// <returns>Type definition for specified object-type.</returns>
        public abstract TypeDefinition GetTypeDefinition(string repositoryId, string typeId);
    }
}
